package com.fubowen.lepton.ui.container.children.download.recycler

import androidx.recyclerview.widget.SortedListAdapterCallback
import com.fubowen.lepton.conf.FileConfig

class DownloadSortedListAdapterCallback(_adapter: DownloadAdapter) :
    SortedListAdapterCallback<FileConfig>(_adapter) {

    override fun compare(prev: FileConfig?, next: FileConfig?): Int {
        if (prev == null || next == null) {
            return 0
        }
        return (next.lastUpdateTime - prev.lastUpdateTime).toInt()
    }

    override fun areContentsTheSame(oldItem: FileConfig?, newItem: FileConfig?): Boolean {
        return oldItem == newItem
    }

    override fun areItemsTheSame(oldItem: FileConfig?, newItem: FileConfig?): Boolean {
        return oldItem?.fullName == newItem?.fullName
    }
}